<script setup>
import { defineProps } from 'vue'

// 接受父组件传递的props，用defineprops定义
defineProps({
    giftList: Array
})

</script>

<template>
    <div class="container">

        <div class="prize">


            <h1>
                <slot name="prize-title"></slot> X {{ giftList.length }}
            </h1>

            <ul>
                <li v-for="(item, index) in giftList" :key="index">
                    {{ item }}
                </li>
            </ul>
        </div>

        <!-- 添加奖池内的物品 在prize下方显示 -->
        <slot name="add-item"></slot>


        <!-- 圆按钮，用来关闭此组件显示 -->
        <div class="close-btn">
            <button @click="$emit('close')">X</button>
        </div>
    </div>

</template>

<style scoped>
/* container覆盖整个页面 */
.container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);

    .prize {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 420px;
        height: 400px;
        border-radius: 10px;
        padding: 20px;
        background-color: #f5f5f5;
        /* 超出使用滚动条 */
        overflow: auto;

        h1 {
            font-size: 24px;
            font-weight: bold;
            text-align: center;
            margin-bottom: 20px;
        }

        ul {
            list-style: none;
            padding: 0;
            margin: 0;
            display: flex;
            flex-wrap: wrap;
            justify-content: center;

            li {
                width: 100px;
                height: 100px;
                margin: 10px;
                text-align: center;
                line-height: 100px;
                border-radius: 5px;
                background-color: #fff;
                color: #333;
                font-size: 18px;
                transition: all 0.3s ease;
            }

        }
    }

    .close-btn {
        position: absolute;
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        background-color: #fff;
        box-shadow: 0 0 5px #ccc;
        cursor: pointer;

        button {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 30px;
            height: 30px;
            border-radius: 50%;
            background-color: #f5f5f5;
            box-shadow: 0 0 5px #ccc;
            cursor: pointer;
        }
    }


}
</style>
